#include "common.h"

#include "uievent.h"
#include "observer.h"
#include "uieventreceiver.h"
#include "ui.h"

#include "interactableui.h"

InteractableUI::InteractableUI()
:	UI()
,	UIEventReceiver()
{
}

void InteractableUI::OnEventReceived()
{
	D3DXVECTOR2 pos			= GetStartPos();
	RECT rect				= GetRect();
	const EventDesc& info	= GetEventInfo();

	switch( info.eventType )
	{
	case EVENT_MOUSE :
		if( pos.x <= info.curPosX && info.curPosX <= pos.x + ( rect.right-rect.left ) &&
			pos.y <= info.curPosY && info.curPosY <= pos.y + ( rect.bottom-rect.top ) )
		{
			OnMouseInPosition();

			if( info.buttonFlag == MOUSE_LDOWN )
			{
				OnMouseLButtonDown();
			}
			if( info.buttonFlag == MOUSE_LUP )
			{
				OnMouseLButtonUp();
			}
		}
		else
		{
			OnMouseOutOfPosition();
		}
		break;
	case EVENT_KEYBOARD :
		break;
	case EVENT_UNKNOWN :
	default :
		break;

	}

	//...
}